<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>只能输入两位数字的正则</title>
</head>
<style>
  body {
    font-size: 12px;
  }
</style>

<body>
  <fieldset>
    <legend>只能输入整数 数字的输入框</legend>
    <input placeholder="金额" oninput="value=value.replace(/[^0-9]/g,'')" />
  </fieldset>

  <fieldset>
    <legend>只能输入数字 可 有两位小数 的输入框</legend>
    <input placeholder="金额" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" />

    <input type="text" oninput="value=value.match(/^\d+(?:\.\d{0,2})?/)" />
  </fieldset>



</body>

</html>